﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CCWin;
namespace SCCM
{
    public partial class DataTableForm : Skin_Mac
    {
        private DataTable dt;
        public DataTableForm()
        {
            InitializeComponent();
            
        }
        public void SetDataTable(DataTable dt)
        {
            this.listTable.DataSource = dt;
            //MessageBox.Show(listTable.Columns[1].ToString());
            //listTable.Columns[1].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm";
        }
        public DataGridView getdgv()
        {
            if (this.listTable != null)
            {
                return listTable;
            }
            else
            {
                return null;
            }

        }
        private void 导出EXCELToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EPPlusHelper.dataGridViewToExcel(getdgv());
        }

        private void listTable_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex == 1 || e.ColumnIndex == 12)
            {
                try
                {

                    e.Value = Convert.ToDateTime(e.Value).ToString("yyyy-MM-dd HH:mm");
                }catch (Exception ex){
                }
            }
        }
    }
}
